package com.wcl.demo.ui.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by dllo on 15/11/20.
 */
public class SplashViewPagerAdapter extends PagerAdapter {

    private List<View> views;

    public void addData(List<View> views) {
        this.views = views;
    }

    @Override
    public int getCount() {
        return views != null && views.size() > 0 ? views.size() : 0;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return (view == object);
    }

    // 销毁position位置的界面
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(views.get(position),0);
//        if(position==views.size()-1){
//
//        }
        return views.get(position);
    }
}
